﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Calculater
{
    public partial class main : Form
    {
        public static double op;
        public static int oc;
        public main()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button1.Text;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button2.Text;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button3.Text;
        }

        private void button10_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button10.Text;
        }

        private void button9_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button9.Text;
        }

        private void button8_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button8.Text;
        }

        private void button15_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button15.Text;
        }

        private void button14_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button14.Text;
        }

        private void button13_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button13.Text;
        }

        private void button20_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button20.Text;
        }

        private void button19_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button19.Text;
        }

        private void button18_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + button18.Text;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
        }

        private void button6_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 1);
        }

        private void main_Load(object sender, EventArgs e)
        {

        }

        private void button17_Click(object sender, EventArgs e)
        {
            op = double.Parse(textBox1.Text);
            oc = 1;
            textBox1.Text = "";
        }

        private void button11_Click(object sender, EventArgs e)
        {
           switch(oc)
            {
                case 1:
                    textBox1.Text = plus(op, double.Parse(textBox1.Text)).ToString();
                    break;
                case 2:
                    textBox1.Text = minus(op, double.Parse(textBox1.Text)).ToString();
                    break;
                case 3:
                    textBox1.Text = mult(op, double.Parse(textBox1.Text)).ToString();
                    break;
                case 4:
                    textBox1.Text = dividsion(op, double.Parse(textBox1.Text)).ToString();
                    break;
            }                                 
        }

        private void button12_Click(object sender, EventArgs e)
        {
            op = double.Parse(textBox1.Text);
            oc = 2;
            textBox1.Text = "";
        }

        private void button7_Click(object sender, EventArgs e)
        {
            op = double.Parse(textBox1.Text);
            oc = 3;
            textBox1.Text = "";
        }

        private void button4_Click(object sender, EventArgs e)
        {

            try
            {
                op = double.Parse(textBox1.Text);
                oc = 4;
                textBox1.Text = "";
            }
            catch (Exception)
            {

                throw;
            }

        }

        public double plus(double s1,double s2)
        {
            double opp;
            opp = s1 + s2;
            return opp;
        }

        public double minus(double s1, double s2)
        {
            double opp;
            opp = s1 - s2;
            return opp;
        }

        public double mult(double s1, double s2)
        {
            double opp;
            opp = s1 * s2;
            return opp;
        }

        public double dividsion(double s1, double s2)
        {
            double opp;
            opp = s1 / s2;
            return opp;
        }
    }
}
